import type { Request, Response, NextFunction } from "express"

export async function adminRoleValidate(
  req: Request,
  res: Response,
  next: NextFunction
) {
  const isAdmin = req.user?.role?.includes("admin") ?? false

  if (!isAdmin) {
    return res
      .status(403)
      .json({ status: "fail", message: "Require admin Role" })
  }

  next()
}
